package Enums;

public class TrafficLight {
	SignalColor signalColor;

	public boolean drivingAllowed() {
		return signalColor.getdrivingAllowed();
	}

	public String getColorOfLight() {
		switch (signalColor) {
		case RED: return "red";
		case YELLOW: return "yellow";
		case GREEN: return "green";
		default: return "dead";
		}
	} 

	public String toString() {
		String driving = (drivingAllowed()) ? "is " : "is not ";
		return "The light is " + getColorOfLight() + "! Driving " + driving + "allowed.";
	}

	private void setSignalColor(SignalColor signal) {
		signalColor = signal;
	}

	public static void main(String[] args) {
		TrafficLight trafficlight = new TrafficLight();
		trafficlight.setSignalColor(SignalColor.GREEN);
		System.out.println(trafficlight);
		trafficlight.setSignalColor(SignalColor.RED);
		System.out.println(trafficlight);
		trafficlight.setSignalColor(SignalColor.YELLOW);
		System.out.println(trafficlight);
	}
}